87f78fb51777cb6cd04710d676487cd7599b49aa,modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java,CodeGenerator,snippet,#Collection#String#boolean#String#ConfirmCallable#,569
Before Change
add0(src, "");
for (Map.Entry<String, Boolean> idxFld : idx.getFields().entrySet())
add2(src, "idxFlds.put(\"" + idxFld.getKey() + "\", " + idxFld.getValue() + ");");
add0(src, "");
After Change
boolean first = true;
boolean firstIdx = true;
for (QueryIndex idx : idxs) {
Set<Map.Entry<String, Boolean>> dbIdxFlds = idx.getFields().entrySet();
int sz = dbIdxFlds.size();
List<T2<String, Boolean>> idxFlds = new ArrayList<>(sz);
for (Map.Entry<String, Boolean> idxFld : dbIdxFlds) {
PojoField field = findFieldByName(pojo, idxFld.getKey());
if (field != null)
idxFlds.add(new T2<>(field.javaName(), idxFld.getValue()));
else
break;
}
// Only if all fields present, add index description.
if (idxFlds.size() == sz) {
if (first) {
add2(src, "// Indexes for " + tbl + ".");
add2(src, "Collection<QueryIndex> idxs = new ArrayList<>();");
add0(src, "");
}
if (sz == 1) {
T2<String, Boolean> idxFld = idxFlds.get(0);
add2(src, "idxs.add(new QueryIndex(\"" + idxFld.getKey() + "\", " + idxFld.getValue() + ", \"" +
idx.getName() + "\"));");
add0(src, "");
}
else {
add2(src, (firstIdx ? "QueryIndex " : "") + "idx = new QueryIndex();");
add0(src, "");
add2(src, "idx.setName(\"" + idx.getName() + "\");");
add0(src, "");
add2(src, (firstIdx ? "LinkedHashMap<String, Boolean> " : "") +
"idxFlds = new LinkedHashMap<>();");
add0(src, "");
for (T2<String, Boolean> idxFld : idxFlds)
add2(src, "idxFlds.put(\"" + idxFld.getKey() + "\", " + idxFld.getValue() + ");");
add0(src, "");